class Teacher():
    # 属性--数据（变量）
    # name = '小王' #类属性
    # 方法--功能（函数）
    # 构造方法---魔术方法--自动调用（对象实例化时）
    def __init__(self, name, age):
        self.name = name  # 实例对象属性
        self.age = age
        print(self, 'Teacher对象创建成功')

    def teach(self):
        print('%s正在讲Python是' % self.name)

    def teachInfo(self):
        print(f'{self.name}的年龄是{self.age}')

    def __str__(self):
        # print('__str__魔术方法被调用')
        return f'Teacher对象{self.name}的年龄是{self.age}'
        # print(f'Teacher对象{self.name}的年龄是{self.age}')

# 实例化对象
teacher1 = Teacher('小王', 18)
print(teacher1)
# print(teacher1)
# print(teacher1)
# print(teacher1)
# print(teacher1.name)
teacher1.teachInfo()

# teacher2 = Teacher('小张', 20)
# print(teacher2)
# print(teacher2.name)
# # print(teacher2.age)
